from __future__ import absolute_import, unicode_literals

from ronglian_sms_sdk import SmsSDK
from celery import shared_task
import random
from common.utils.myredis import myredis


@shared_task
def send_message(mobile):
    accId = '8aaf07087de13e49017dff06e47f0668'
    accToken = '45d7fd5f37784526b6eb324950513a50'
    appId = '8aaf07087de13e49017dff06e586066f'
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    sms_id = random.randint(100000, 999999)
    datas = (sms_id,)
    print('mobile', mobile)
    myredis.img_code_set("sms_%s" % mobile, 60 * 5, sms_id)
    resp = sdk.sendMessage(tid, mobile, datas)
    return resp